<?php

declare(strict_types=1);

namespace App\CustHub\Controller;

use App\CustHub\Annotation\ApiAuth;
use App\CustHub\Annotation\VerifySignature;
use App\CustHub\Request\RoomInviteAcceptRequest;
use App\CustHub\Service\ChRoomInviteAcceptConfigService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\PostMapping;

#[Controller('ch/room/invite/accept'),ApiAuth,VerifySignature]
class RoomInviteAcceptConfigController extends BaseController
{
    #[Inject]
    protected ChRoomInviteAcceptConfigService $service;

    #[PostMapping('list')]
    public function list(): \Psr\Http\Message\ResponseInterface
    {
        return $this->success($this->service->getConfigList($this->request->all()));
    }


    /**
     * 保存配置
     * @param RoomInviteAcceptRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     * @throws \Psr\Container\ContainerExceptionInterface
     * @throws \Psr\Container\NotFoundExceptionInterface
     */
    #[PostMapping('save')]
    public function save(RoomInviteAcceptRequest $request): \Psr\Http\Message\ResponseInterface
    {
        return $this->service->saveConfig($request->all()) ? $this->success() : $this->error();
    }

    /**
     * 修改配置
     * @param RoomInviteAcceptRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     * @throws \Psr\Container\ContainerExceptionInterface
     * @throws \Psr\Container\NotFoundExceptionInterface
     */
    #[PostMapping('update')]
    public function update(RoomInviteAcceptRequest $request): \Psr\Http\Message\ResponseInterface
    {
        return $this->service->updateConfig($request->input('id'),$request->all()) ? $this->success() : $this->error();
    }

    /**
     * 删除配置
     * @param RoomInviteAcceptRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     * @throws \Psr\Container\ContainerExceptionInterface
     * @throws \Psr\Container\NotFoundExceptionInterface
     */
    #[PostMapping('delete')]
    public function delete(RoomInviteAcceptRequest $request): \Psr\Http\Message\ResponseInterface
    {
        return $this->service->deleteConfig($request->input('id')) ? $this->success() : $this->error();
    }

    /**
     * 接受记录
     * @param RoomInviteAcceptRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     * @throws \Psr\Container\ContainerExceptionInterface
     * @throws \Psr\Container\NotFoundExceptionInterface
     */
    #[PostMapping('getRecordList')]
    public function getRecordList(RoomInviteAcceptRequest $request): \Psr\Http\Message\ResponseInterface
    {
        return $this->success($this->service->getRecordList($request->all()));
    }
}